/*
 * @lc app=leetcode.cn id=5 lang=javascript
 *
 * [5] 最长回文子串
 */

// @lc code=start∏
/**
 * @param {string} s
 * @return {string}
 */
var longestPalindrome = function(s) {
    let n = s.length;
    while(n > 0) {
        let start = 0;
        let end = start + n;
        while(end <= s.length) {
            let maxStr = s.substring(start,end);
            const isMaxStr = judge(maxStr);
            if(isMaxStr) {
                return maxStr;
            }
            start++;
            end++;
        }
        n--;
    }
};
var judge = function(s) {
    let i = 0;
    let j = s.length - 1;
    while(i <= j) {
        if(s[i] !== s[j]) {
            return false;
        }
        i++;
        j--;
    }
    return true;
}
// @lc code=end

